package 代码记录.指定公司代码练习记录.腾讯云智.算法21年;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author zx
 * @create 2023-03-21 0:03
 */
public class 整数列表求三的倍数_nowcoder {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 1;i <= n;i++) {
            list.add(i);
        }
        int m = 1;
        while(list.size() != 1){
            for (int i = 0; i < list.size();i++) {
                if(m > 3){
                    m = 1;
                }
                if(m % 3 == 0){
                    list.remove(i);
                    i--;
                }
                m++;
            }
        }
        System.out.println(list);
    }
}
